<?php
abstract class Model {
	protected $registry;
    protected $pdo;
    protected $site_id;
    protected $language_id;
    protected $db_prefix;
	
	public function __construct($registry) {

		$this->registry     = $registry;
        $this->pdo          = null;
        $this->db_prefix    = "";
        $this->site_id      = 0;

        if($registry->has('pdo')){
            $this->pdo = $registry->get('pdo');
        }

        if($registry->has('setting')){

            if($registry->get('setting')->has('db_prefix')) {
                $this->db_prefix = $registry->get('setting')->get('db_prefix');
            }

            if($registry->get('setting')->has('setting_store_id')) {
                $this->site_id = (int)$this->setting->get('setting_store_id');
            }
            
            if($registry->get('setting')->has('setting_language_id')) {
                $this->language_id = (int)$this->setting->get('setting_language_id');
            }
        }
	}
	
	public function __get($key) {
		return $this->registry->get($key);
	}
	
	public function __set($key, $value) {
		$this->registry->set($key, $value);
    } 
}
?>
